using System;
using System.Collections.Generic;
using System.Text;
using System.Security;
using System.Runtime.Serialization;

namespace InfiniTec.Security
{
    /// <summary>
    /// This exception is always thrown when no valid credential could be acquired for the 
    /// <see cref="ImpersonationScope"/>.
    /// </summary>
    [Serializable]
    public class CredentialInputCancelledException: Exception
    {
        private string _TargetName;

        /// <summary>
        /// Returns the target name for the failed Scope.
        /// </summary>
        public string TargetName
        {
            get { return _TargetName; }
        }

        /// <summary>
        /// Initializes a new instance of this class using the specified <see cref="TargetName"/>
        /// </summary>
        /// <param name="targetName">The target name of the failed request.</param>
        public CredentialInputCancelledException(string targetName) : this(targetName, "")  { }
        /// <summary>
        /// Initializes a new instance of this class with a specified error message and target name.
        /// </summary>
        /// <param name="targetName">The target name of the failed request.</param>
        /// <param name="message">The message that describes the error.</param>
        public CredentialInputCancelledException(string targetName, string message)
            : this(message, targetName, null) { }
        /// <summary>
        /// Initializes a new instance of this class with a specified error message and target name.
        /// </summary>
        /// <param name="targetName">The target name of the failed request.</param>
        /// <param name="message">The message that describes the error.</param>
        /// <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
        public CredentialInputCancelledException(string targetName, string message, Exception innerException)
            : base(message, innerException)
        {
            _TargetName = targetName;
        }
        /// <summary>
        /// Initializes a new instance of this class with a specified error message and target name.
        /// </summary>
        /// <param name="context">A <see cref="StreamingContext"/> instance</param>
        /// <param name="info">A <see cref="SerializationInfo"/> instance</param>
        protected CredentialInputCancelledException(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
        }

    }
}
